package com.yunhe.tianhe.rentcars.controller.returnCars;

import com.yunhe.tianhe.rentcars.dto.JSONResponse;
import com.yunhe.tianhe.rentcars.entity.cheliangguanli.ZuYong;
import com.yunhe.tianhe.rentcars.entity.system.Dept;
import com.yunhe.tianhe.rentcars.service.returnCars.ReturnCarsService;
import com.yunhe.tianhe.rentcars.service.system.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @user yanxiu
 * @creat 2017-12-03 16:10
 * @desc
 **/
@Controller
@RequestMapping("/return")
public class ReturnBackController {

    @Autowired
    private ReturnCarsService returnCarsService;
    @Autowired
    private DeptService deptService;

    @RequestMapping
    public String view(HttpServletRequest req) {
        List<Dept> deptList = deptService.findList();
        req.setAttribute("deptList",deptList);
        return "returnCars/returnBack";
    }

    @RequestMapping("/orderAjax")
    @ResponseBody
    public JSONResponse order(long orderId) {
        JSONResponse success=null;
        ZuYong order= returnCarsService.findOrder(orderId);
        if(null!=order){
            success=JSONResponse.success("请完成还车登记",order);
        }else if(null==order) {
            success=JSONResponse.fail("无此订单，请确认订单号",order);
        }
        return success;
    }

    @RequestMapping("/kong")
    public String kong(){
        return "/returnCars/kong";
    }

    @RequestMapping("/shouchu")
    public String shouchu(){
        return "/returnCars/shouchu";
    }

    @RequestMapping("/zichu")
    public String zichu(){
        return "/returnCars/zichu";
    }

    @RequestMapping("/plan")
    public String plan(){
        return "returnCars/shuo";
    }

    @RequestMapping("/zhuo")
    public String zhuo(){
        return "returnCars/zhuo";
    }
    @RequestMapping("/yuan")
    public String yuan(){
        return "returnCars/yuan";
    }

    @RequestMapping("/ku")
    public String ku(){
        return "returnCars/ku";
    }
}
